home *** CD-ROM | disk | FTP | other *** search
- /*
- main.c
-
- This file contains the main routine, some globals, and that's about it.
-
- Created 9/2/92 - Dave Hersey
-
- ----------------------------------------------
-
- 2/93 debugged and plopped on GX CD. - dmh
- 9/93 updated to run with the ß2 "GXified" interface files - PLA
- 9/93 Added override for gxPrintingEvent to handle update events. - dmh
- 5/94 PrintingEvent override now only handles appropriate events. - dmh
- 8/94 Universalized. - dmh
- */
-
- #include <Resources.h>
- #include <Desk.h>
- #include <Events.h>
- #include <Fonts.h>
- #include <Windows.h>
- #include <Memory.h>
- #include <ToolUtils.h>
- #include <Quickdraw.h>
-
- #include <GXPrinting.h>
- #include <GXEnvironment.h>
- #include <GXGraphics.h>
- #include <GraphicsLibraries.h>
- #include <GXErrors.h>
- #include "Banana Jr.h"
-
- Boolean gQuitting;
- Str255 gWindowTitle = "\pQuickDraw GX is cool...";
- Rect gWindowQDRect = {50, 15, 512, 580};
- Boolean gDebugging = false;
- Boolean gGiveMeValidation = false;
- long gGraphicsHeapSize = 500;
- short gAppResRefNum;
- long gSleep = 0;
-
- void main()
- {
- CursHandle theCurs;
- Handle menuBar;
- gxGraphicsClient client;
- OSErr err;
- WindowPtr wind;
- char i;
-
- gAppResRefNum = CurResFile();
- client = GXNewGraphicsClient(nil, gGraphicsHeapSize * 1024L, 0L);
-
- MaxApplZone();
-
- for (i = 1; i <= 6; i++)
- MoreMasters();
-
- if (gDebugging)
- {
- SetGraphicsLibraryErrors ();
- SetGraphicsLibraryNotices();
- }
-
- if (gGiveMeValidation) GXSetValidation(gxPublicValidation);
-
-
- /** Initialize the new graphics and printing environments. **/
-
- GXEnterGraphics();
- err = GXInitPrinting();
-
- /** Initialize the other managers, if no errors occured. **/
-
- if (!err)
- {
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- InitCursor();
-
- theCurs = GetCursor(watchCursor);
- SetCursor(*theCurs);
-
- menuBar = GetNewMBar(rMenuBar);
-
- if (menuBar)
- {
- gQuitting = false;
- SetMenuBar(menuBar);
- DisposHandle(menuBar);
- AddResMenu(GetMHandle(mApple), 'DRVR');
- DrawMenuBar();
-
- // We initialize the CommonColors Library. This will allow us to set the color of a
- // shape by calling the SetShapeCommonColor function. We will need to call
- // DisposeCommonColors when we leave, to clean up the world.
-
- InitCommonColors();
-
- DoCreateNew();
- SetCursor(&qd.arrow);
-
- while (!gQuitting)
- EventLoop();
-
-
- // Leaving. Close all the windows so we get rid of any data we or GX created. Then,
- // dispose of the common colors and exit the GX printing and graphics environment.
-
- while (wind = FrontWindow())
- DoDispose(wind);
-
- DisposeCommonColors();
- }
-
- GXExitPrinting();
- }
-
- GXExitGraphics();
- GXDisposeGraphicsClient(client);
- }
-
-
- /*------ MyPrintingEventOverride -----------------------------------------------------------------------------*/
- // Override for GXPrintingEvent. It allows us to update our windows
- // when the moveable modal printing dialogs are moved.
-
- OSErr MyPrintingEventOverride(EventRecord *anEvent, Boolean filterEvent)
- {
- OSErr err = noErr;
-
- // Handle events in whatever way is appropriate. MyDoEvent is our
- // generic event handler. We don't pass it events that it shouldn't
- // handle while print dialogs are displayed.
-
- if (!filterEvent)
- switch (anEvent->what)
- {
- case mouseDown:
- case keyDown:
- case autoKey:
- break;
-
- default:
- MyDoEvent(anEvent);
- }
-
- return err;
- }
-
-
-